package mo.daliy;

import java.util.ArrayList;
import java.util.List;

public class L784 {

    public List<String> letterCasePermutation(String s) {
        List<String> res = new ArrayList<>();
        dfs(res, 0, s.toCharArray());
        return res;
    }

    private void dfs(List<String> combination, int index, char[] arr) {
        if (index == arr.length) {
            combination.add(new String(arr));
            return;
        }
        dfs(combination, index+1, arr);
        if (Character.isLetter(arr[index])) {
            arr[index] ^= 1<<5;
            dfs(combination, index+1, arr);
        }
    }

}
